<template>
  <el-cascader
    :show-all-levels="false"
    :options="tree"
    :props="{ value:'id',label:'name',checkStrictly: true}"
    v-model="val"
    :disabled="disabled"
    @change="$emit('change',$event)"
  />
</template>
<script>
// import name from "./name";
export default {
  // components: { name},
  props: ["data", "disabled"],
  watch: {
    "gd.userType"() {
      this.setTree();
    },
    data() {
      this.setTree();
    }
  },
  data() {
    return {
      tree: [],
      val: []
    };
  },
  // computed() {return{}},
  created() {
    this.setTree();
  },
  methods: {
    tst(a, b) {
      console.log(a, b);
    },
    setTree() {
      if (this.$isset(this.$gd.userType)) {
        this.tree = this.$gd.userType.arr2tree();
        if (this.$isset(this.data)) {
          let d = this.$cp(this.data);
          if (typeof d == "number" || typeof d == "string") {
            this.val = this.$gd.userType.getTreeID(Number(d));
          } else this.val = d;
        }
      }
    }
  }
};
</script>

<style lang="less" scoped>
</style>
